<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>展示文章</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://cdn.bootcss.com/vue-resource/1.5.0/vue-resource.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
    <div id="article-container">
        <h1>{{article.TITLE}}</h1>
        <hr>
        作者：{{article.AUTHORID}}&nbsp;&nbsp;时间：{{article.CREATE_TIME}}<br/>
        <hr>
            <div id="content">
            <span v-html="markContent"></span>
            </div>
    </div>
    
</body>
<script>
    function GetRequest() { 
        var url = location.search; //获取url中"?"符后的字串 
        var theRequest = new Object(); 
        if (url.indexOf("?") != -1) { 
        var str = url.substr(1); 
        strs = str.split("&"); 
        for(var i = 0; i < strs.length; i ++) { 
        theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); 
        } 
        } 
        return theRequest; 
    } 
    var vm = new Vue({
        el : "#article-container",
        data : {article:{}},
        created : function(){
            this.$http.get("http://localhost/api/article/show?id="+GetRequest()['id']).then(function(data){
                this.article = data.body;
            });
        },
        computed : {
            markContent : function(){
                return marked(this.article.CONTENT?this.article.CONTENT:"")
            }
        }
    });
</script>
</html>